using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    /// <summary> 
    ///Author: nnamthach@gmail.com 
    /// <summary>
    public class ContractDetailControl
    {
        #region Local Variable
        private ContractDetailDataAccess _ContractDetailDAO;
        #endregion Local Variable

        #region Method
        public ContractDetailControl()
        {
            _ContractDetailDAO = new ContractDetailDataAccess();
        }

        public ContractDetailInfo Get_ContractDetail(
            Int32 ID
        , ref string sErr)
        {
            return _ContractDetailDAO.Get_ContractDetail(
            ID
            , ref sErr);
        }


        public ContractDetailInfo Get_ContractDetail1(
           Int32 ID
       , ref string sErr)
        {
            return _ContractDetailDAO.Get_ContractDetail1(
            ID
            , ref sErr);
        }

        public DataTable GetAll_ContractDetail(ref string sErr)
        {
            return _ContractDetailDAO.GetAll_ContractDetail(ref sErr);
        }

        public DataTable GetAll_ContractDetail1(ref string sErr)
        {
            return _ContractDetailDAO.GetAll_ContractDetail1(ref sErr);
        }

        public Int32 Add_ContractDetail(ContractDetailInfo obj, ref string sErr)
        {
            return _ContractDetailDAO.Add_ContractDetail(obj, ref sErr);
        }

        public Int32 Add_ContractDetail1(ContractDetailInfo obj, ref string sErr)
        {
            return _ContractDetailDAO.Add_ContractDetail1(obj, ref sErr);
        }

        public string Update_ContractDetail(ContractDetailInfo obj)
        {
            return _ContractDetailDAO.Update_ContractDetail(obj);
        }

        public string Update_ContractDetail1(ContractDetailInfo obj)
        {
            return _ContractDetailDAO.Update_ContractDetail1(obj);
        }

        public string Delete_ContractDetail(
            Int32 ID
        )
        {
            return _ContractDetailDAO.Delete_ContractDetail(
            ID
            );
        }

        public string Delete_ContractDetail1(
            Int32 ID
        )
        {
            return _ContractDetailDAO.Delete_ContractDetail1(
            ID
            );
        }

        public Boolean IsExist_ContractDetail(
            Int32 ID
        )
        {
            return _ContractDetailDAO.IsExist_ContractDetail(
            ID
            );
        }

        public Boolean IsExist_ContractDetail1(
           Int32 ID
       )
        {
            return _ContractDetailDAO.IsExist_ContractDetail1(
            ID
            );
        }

        /*  public string Delete_ContractDetail(String arrID)
          {
              string kq = "";
              string[] arrStrID = arrID.Split(',');
              foreach (string strID in arrStrID)
              {
                  if (strID != "")
                  {
                      int ID = Convert.ToInt32(strID);
                      kq += _ContractDetailDAO.Delete_ContractDetail(ID);
                  }
              }
              return kq;
          } */


        public DataTable Search(String columnName, String columnValue, String condition, ref String sErr)
        {
            return _ContractDetailDAO.Search(columnName, columnValue, condition, ref  sErr);
        }

        #endregion Method


        public int Add(string busId, ContractDetailInfo info, ref string sErr)
        {
            if (busId == "HL") return Add_ContractDetail(info, ref sErr);
            return Add_ContractDetail1(info, ref sErr);
        }

        public string Update(string busId, ContractDetailInfo info)
        {
            if (busId == "HL") return Update_ContractDetail(info);
            return Update_ContractDetail1(info);
        }

        public bool SetTransaction(object trans)
        {
            return _ContractDetailDAO.SetTransaction(trans);
        }

        public string Delete(string busId, string contract)
        {
            if (busId == "HL") return _ContractDetailDAO.DeleteHL(contract);
            return _ContractDetailDAO.DeleteHV(contract);

        }

        public DataTable GetAll(string busId,string contract, ref string sErr)
        {
            if (busId == "HL") return _ContractDetailDAO.GetAllHL(contract, ref sErr);
            return _ContractDetailDAO.GetAllHV(contract, ref sErr);
        }
    }
}
